package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;

import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.service.ApUserSearchService;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 历史记录表现层
 */
@RestController
@RequestMapping("/api/v1/history")
public class HistoryController {

    @Resource
    private ApUserSearchService apUserSearchService;

    /**
     * 加载历史记录
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(){
        return apUserSearchService.loadHistory();
    }

    /**
     * 删除历史记录
     * @param dto
     * @return
     */
    @PostMapping("/del")
    public ResponseResult delHistory(@RequestBody HistorySearchDto dto){
        return apUserSearchService.delHistory(dto);
    }
}
